package com.rc.saas.tenant.service.elec;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.mapper.device.RcLabelMapper;
import com.rc.saas.tenant.model.device.RcLabel;
import com.rc.saas.tenant.model.device.RcLabelExample;
import com.rc.saas.tenant.search.elec.ElecLabelSearch;
import com.rc.saas.tenant.vo.device.RcLabelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by sven on 2018-04-17
 */
@Service
public class ElecLabelServiceImpl implements ElecLabelService {

    @Autowired
    private RcLabelMapper rcLabelMapper;


    @Override
    public RcLabelMapper getMapper() {
        return rcLabelMapper;
    }

    @Override
    public void saveLabel(RcLabel rcLabel) {
        rcLabelMapper.saveLabel(rcLabel);
    }

    @Override
    public PageInfo<RcLabelVo> listPageByCondition(ElecLabelSearch elecLabelSearch) {
        PageHelper.startPage(elecLabelSearch.getOffset(), elecLabelSearch.getLimit());
        List<RcLabelVo> elecLabelList =  rcLabelMapper.listPageByCondition(elecLabelSearch);
        return new PageInfo<RcLabelVo>(elecLabelList);
    }

    @Override
    public List<RcLabel> loadLabel() {
        RcLabelExample example = new RcLabelExample();
        example.createCriteria().andStatusEqualTo("1");
        List<RcLabel> rcLabels = rcLabelMapper.selectByExample(example);
        return rcLabels;
    }

    @Override
    public String getLabelNames(String labelIds) {
        return rcLabelMapper.getLabelNames(labelIds);
    }


}
